require('./curriculum.less')


//引入字体图标
require('../../libs/fonts/iconfont.css')

//引入底部导航
const { showNav, showtopNav } = require('../../utlis/footer-')
showNav('run')
showtopNav('curriculum')

//引入axios
const axios = require('axios')

//引入dom.js
const { $, g, ga } = require('../../utlis/dom')


$(function () {
    axios.get('http://47.96.154.185:3701/api/train/courseList').then(function (res) {
        // console.log(res)
        if (res.data.errno === 0) {
            //console.log(res.data.data)
            let courseList = res.data.data
            let firstCourse = courseList.shift()//第一个元素

            //最新课程渲染
            g('#newImg').src = 'http://47.96.154.185:3701' + firstCourse.imgurl
            g('#newTitle').textContent = firstCourse.name
            g('#newText').textContent = firstCourse.desc

            //课程渲染
            let html = ''
            //console.log(courseList)
            courseList.forEach(function (v) {
                html += `
                    <a href="./details.html#${v.courseId}" class="box-new">
                        <div class="new-pic"><img src="http://47.96.154.185:3701${v.imgurl}" alt=""></div>
                        <div class="new-text">
                            <p>${v.name}</p>
                            <p>${v.desc}</p>
                        </div>
                    </a>
                `
            })
            g('.culum').innerHTML=html
            
        }
    })
})
